package com.koala.aideddevsystemmodule.modules.cacheBreakdown.controller;

import java.util.Arrays;
import java.util.Map;

import com.koala.aideddevsystemmodule.modules.cacheBreakdown.entity.CacheBreakdownEntity;
import com.koala.aideddevsystemmodule.modules.cacheBreakdown.service.CacheBreakdownService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.koala.aideddevsystemmodule.utils.PageUtils;
import com.koala.aideddevsystemmodule.utils.R;

/**
 * Create by koala on 2022-08-22 21:58:38
 */
@RestController
@RequestMapping("/cacheBreakdown")
public class CacheBreakdownController {
    @Autowired
    private CacheBreakdownService cacheBreakdownService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cacheBreakdownService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/getCacheBreakdownEntityById/{id}")
    public R getCacheBreakdownEntityById(@PathVariable("id") String id){
		CacheBreakdownEntity cacheBreakdown = cacheBreakdownService.getCacheBreakdownEntityById(id);

        return R.ok().put("cacheBreakdown", cacheBreakdown);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CacheBreakdownEntity cacheBreakdown){
		cacheBreakdownService.save(cacheBreakdown);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CacheBreakdownEntity cacheBreakdown){
		cacheBreakdownService.updateById(cacheBreakdown);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
		cacheBreakdownService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
